/*
 * T.Raynal - A.Aviles - F.Diallo
 * XML-Scenarios
 * PPA AL5-2
 * December 2012 
 */
package output;

import java.io.File;
import java.io.IOException;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Result;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;

import org.w3c.dom.Document;
import org.xml.sax.SAXException;

import common.exception.InitialisationException;


public class TestXSL {
	
	static Document document;
	
   public static void main (String args[]) throws InitialisationException, IOException
    {
	  	try {
			RUN("C:\\Users\\t-raynal\\Desktop\\MyXML.txt",
					  "C:\\Users\\t-raynal\\Desktop\\myXSL.txt",""
					);
		} catch (Exception e) {
			e.printStackTrace();
		}
    }
	
	public static void RUN(String xml, String xsl, String html) throws Exception
	{
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        
            File stylesheet = new File(xsl);
            File datafile = new File(xml);

            DocumentBuilder builder = factory.newDocumentBuilder();
            document =builder.parse(datafile);

            TransformerFactory tFactory = TransformerFactory.newInstance();
            StreamSource stylesource = new StreamSource(stylesheet);
            Transformer transformer = tFactory.newTransformer(stylesource);

            DOMSource source = new DOMSource(document);
            StreamResult result = new StreamResult(System.out);
            transformer.transform(source, result);    

    }

}

